classes = [
    {"name": "n_1", "age": 18, "grade": "A"},
    {"name": "n_2", "age": 19, "grade": "B"},
    {"name": "n_3", "age": 21, "grade": "D"},
    {"name": "n_4", "age": 24, "grade": "A"},
    {"name": "n_5", "age": 26, "grade": "C"},
    {"name": "n_6", "age": 23, "grade": "A"},
    {"name": "n_7", "age": 20, "grade": "B"},
    {"name": "n_8", "age": 17, "grade": "C"},
]

# #第一问，按grade排序
l = classes
l. sort(key=lambda x: x["grade"])
print(l)

# #第二问，filter出grade为A的同学
f = filter(lambda x: x["grade"] == "A", classes)
list(f)
# #也可以 print(f)

#第三问，使用Map函数让每个人的age加1
def add(n):
    n["age"] += 1
    return n

m = map(add, classes)
list(m)

#第四问，斐波那契递归函数
def fibs(n):
    if (n >= 0 and n <= 1):
        return 1
    else:
        return fibs(n - 1) + fibs(n - 2)
for i in range(10):
    print(fibs(i), end=" ")